﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;

namespace JsStubGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            Assembly assembly = Assembly.LoadFile(args[0]);
            NamespaceFragment root = new NamespaceFragment();
            foreach (Type type in assembly.GetExportedTypes())
            {
                root.Register(type.Namespace, type);
            }

            TextWriter writer;
            if (args.Length > 1)
                writer = File.CreateText(args[1]);
            else
                writer = Console.Out;
            root.Render(writer);
            if (args.Length > 1)
                writer.Close();
            Console.ReadLine();
        }
    }
}
